/*
 * @Author: lucina
 * @Date: 2024-01-25 21:13:30
 * @Description: 项目全局弹框
 */

/**
 * @description: 微信toast
 * @param {*} title
 * @param {*} icon
 * @return {*}
 */
export function toast(title,icon = 'none') {
    wx.showToast({
    title,
    icon: icon,
    duration: 2000
    })

}
/**
 * @description: 微信model
 * @param {*} title
 * @param {*} content
 * @param {*} showCancel
 * @param {*} cancelText
 * @param {*} confirmText
 * @param {*} successCallback
 * @return {*}
 */
export function model(title,content,showCancel=true,cancelText='我知道了',confirmText='确定',successCallback=function(){},errorCallback=function(){},cancelColor="#666",confirmColor="#FE8618"){
    wx.showModal({
        title,
        content,
        showCancel,
        cancelText,
        confirmText,
        cancelColor:cancelColor,
        confirmColor:confirmColor,
        
        success (res) {
            if (res.confirm) {
                successCallback && successCallback()
            } else if (res.cancel) {
                console.log('拒绝')
                errorCallback && errorCallback()

            }
        }
    })
}

/**
 * @description: 微信toast
 * @param {*} title
 * @param {*} icon
 * @return {*}
 */
 export function showLoading(title,mask = true) {
    wx.showLoading({
        title: title,
        mask: mask,
      })

}
/**
 * @description: 微信toast
 * @param {*} title
 * @param {*} icon
 * @return {*}
 */
 export function hideLoading(noConflict=true,failCallBack) {
    wx.hideLoading({
    noConflict:noConflict,
        fail() {
            failCallBack && failCallBack()
        }
    })

}

